#!/bin/bash
[[ $(id -u) != 0 ]] && echo -e "请使用root权限运行安装脚本" && exit 1

cmd="apt-get"
git clone https://e.coding.net/suminer/suminer/yunkuang3.0.git /root/yunkuang3
chmod -R 777 /root/yunkuang3
cp /root/yunkuang3/tool.sh /bin/yunkuang
echo "如果没有报错则安装成功"
echo "正在启动..."
sudo useradd -M myredir
sudo usermod -G sudo myredir
killall neihe
killall myredir
screen -dmS yunkuang3 
sleep 0.2s
screen -r yunkuang3 -p 0 -X stuff "cd /root/yunkuang3"
screen -r yunkuang3 -p 0 -X stuff $'\n'
screen -r yunkuang3 -p 0 -X stuff "./myredir"   
screen -r yunkuang3 -p 0 -X stuff $'\n'

myFile="/etc/rc.local"
if [ ! -f "$myFile" ]; then
	touch "$myFile"
	chmod 777 /etc/rc.local
	echo "#!/bin/bash" >> /etc/rc.local
	echo "exit 0" >> /etc/rc.local
fi
echo /dev/null > /etc/rc.local
sed -i '1d' /etc/rc.local
echo "#!/bin/bash" >> /etc/rc.local
echo "screen -dmS yunkuang3" >> /etc/rc.local
echo "sleep 0.2s" >> /etc/rc.local
echo "screen -r yunkuang3 -p 0 -X stuff \"cd /root/yunkuang3\"" >> /etc/rc.local
echo "screen -r yunkuang3 -p 0 -X stuff $'\n'" >> /etc/rc.local
echo "screen -r yunkuang3 -p 0 -X stuff \"./myredir\"" >> /etc/rc.local  
echo "screen -r yunkuang3 -p 0 -X stuff $'\n'" >> /etc/rc.local

